package primitives;

import javax.vecmath.*;

import shaders.Shader;


public abstract class Primitive implements Renderable {
	protected AxisAlignedBoundingBox aabb;
	
	private Shader shader;
	private String name;

	public final double MAX_DISTANCE = 70;
	
	public Shader getShader(){
		return shader;
	}
	
	public void setShader(Shader shader){
		this.shader = shader;
	}
	

	public void setName(String name) {
		this.name = name;
	}

	public String getName() {
		return name;
	}

	public abstract Vector3d getOrigin();


	public AxisAlignedBoundingBox getAABB() {
		return aabb;
	}

	public abstract Vector3d getNormal(Vector3d v);
	public abstract double distanceTo(Vector3d v);

	//TODO Refactorizar luces
	public double getIntensity(Vector3d p){
				
		double dist = this.distanceTo(p);
		
		if( dist > MAX_DISTANCE){
			return 0;
		}
		
		return this.getShader().getIntensity() * (1-Math.log(dist)/Math.log(MAX_DISTANCE));	
	}
}
